$(document).ready(function() {
  var wheight = $(window).height();
  var hheight = $("#page_header").resize()[0].scrollHeight;
  var bheight = wheight - 2 * hheight;
  $("#page_content").css("height", bheight + "px");

  $("tr[overstyle='on']").hover(
    function() {
      $(this).addClass("bg_hover");
    },
    function() {
      $(this).removeClass("bg_hover");
    }
  );

  $("img[showbigimage='true']").click(function(e) {
    var display = $("#details").css("display");
    if (display == "none" || $("#detailImg").attr("src") != $(this).attr("src")) {
      $("#detailImg").attr("src", $(this).attr("src"));
      $("#details").css("top", e.pageY).css("left", e.pageX).css("display", "block");
      $("#details").css("display", "block");
    } else {
      $("#details").css("top", e.pageY).css("left", e.pageX).css("display", "block");
      $("#details").css("display", "none");
    }

  });
});

      function cancleImg() {
        $("#details").css("display", "none");
      }

      function checkon(o) {
        if (o.checked == true) {
          $(o).parents('tr').addClass('bg_on');
        } else {
          $(o).parents('tr').removeClass('bg_on');
        }
      }

      function del(id, tip, type) {
        var ids = id ? id : getChecked();
        var cnum = id ? 1 : ids.length;
        ids = ids.toString();
        if (ids == null || ids == 0) {
          ui.error('请选择要' + tip + '的数据');
          return false;
        }

        if (type === 'del') {
          if (confirm('{$Think.lang.确定删除？}')) {
            $.post("{:URL('cms/Article/delArticle',array('cid'=>$cid,'sid'=>$sid))}", {
              ids: ids,
              cnum: cnum
            }, function(res) {
              if (res == '1') {
                ui.success('{$Think.lang.删除成功}');
                removeItem(ids);
              } else {
                ui.error('{$Think.lang.删除失败}');
              }
            });
          }
        } else {
          $.post("{:URL('cms/Article/oper')}", {
            ids: ids,
            type: type
          }, function(res) {
            if (res == '1') {
              ui.success(tip + '成功');
              window.location.href = "{:URL('cms/Article/content', array('cid'=>$cid,'sid'=>$sid,'title'=>$title,'sh'=>$sh,'selectAll'=>$selectAll,'status'=>$status))}";
            } else {
              ui.error(tip + '失败');
            }
          });
        }
      }

      function p_content(values, cid, classId) {
        var str_get = "&cid=" + cid + "&classId=" + classId + "&type=" + values;
        if (values == 'article') {
          location.href = "{:URL('cms/Article/addcontent',array('sid'=>$sid))}" + str_get;
        } else if (values == 'video') {
          location.href = "{:URL('cms/Article/addcontent',array('sid'=>$sid))}" + str_get;
        } else if (values == 'pic') {
          location.href = "{:URL('cms/Article/addcontent',array('sid'=>$sid))}" + str_get;
        }
      }

      function move(ad_id, direction) {
        var baseid = direction == 'up' ? $('#' + ad_id).prev().attr('id') : $('#' + ad_id).next().attr('id');
        if (baseid) {
          $.post("{:URL('cms/Article/display_order')}", {
            id: ad_id,
            baseid: baseid
          }, function(res) {
            if (res == '1') {
              direction == 'up' ? $('#' + ad_id).insertBefore('#' + baseid) : $("#" + ad_id).insertAfter('#' + baseid);
            }
          });
        }
      }

      function pushcontent() {
        var ids = getChecked();
        ids = ids.toString();
        if (ids == null || ids == 0) {
          ui.error('{$Think.Lang.请选择要删除的数据}');
          return false;
        }
        if (confirm('{$Think.lang.确定推送选择内容？}')) {
          var str_get = "&ids=" + ids;
          location.href = "{:URL('admin/Push/apppush',array('cid'=>$cid,'sid'=>$sid))}" + str_get;
        }
        })
